import { mock } from "mockjs";
const data = [
  {
    id:0,
    articleName:"ddddd",
    time:"20180921",
    pageView:12,
    img:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595772474325&di=bfd36d13e7fcbe026dfae1167aca6f04&imgtype=0&src=http%3A%2F%2Fa3.att.hudong.com%2F14%2F75%2F01300000164186121366756803686.jpg"
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  },
  {
    articleName:"ddddd",
    time:"20180921",
    pageView:12
  }
]
function group(array, subGroupLength) {
  let index = 0;
  let newArray = [];
  while(index < array.length) {
      newArray.push(array.slice(index, index += subGroupLength));
  }
  return newArray;
}
export default [
  {
    url: "/article/newarticle",
    type: "post",
    response: (config) => {
      console.log(config)
        return {
          code: 200,
          msg: "success",
          data: null
        }
    },
  },
  {
    url: "/article/getList",
    type: "post",
    response: (config) => {
      let  {
        pageNo,
        pageSize
    } = config.body
      return {
        code: 200,
        msg: "success",
        "totalCount": data.length,
        data:group(data,pageSize)[pageNo-1]
      };
    },
  },
  {
    url: "/article/doDelete",
    type: "post",
    response: (config) => {
      return {
        code: 200,
        msg: "模拟删除成功",
      };
    },
  },
];
